#ifndef _LOGGER_UTILS_H__
#define _LOGGER_UTILS_H__
#ifdef __cplusplus
extern "C"
{
#endif

#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <stdarg.h>

#include "klogger/bbh_logger.h"

enum enum_logger_level {
    LOGGER_LEVEL_DEBUG = 0,
    LOGGER_LEVEL_INFO,
    LOGGER_LEVEL_NOTICE,
    LOGGER_LEVEL_WARN,
    LOGGER_LEVEL_ERROR,
    LOGGER_LEVEL_FATAL
};


int   logger_init(const char*filepath, int rolling_interval, int rolling_size, int rolling_keep_num, const char*output_format);
void  logger_uninit();
bbh_logger_t*  logger_instance();

#define klogger_write(log, level, buf, buf_len) \
	bbh_logger_write(log, __FILE__, sizeof(__FILE__)-1, __func__, sizeof(__func__)-1, __LINE__, \
	level, buf, buf_len)

#define klogger_print(log, level, format, args...) \
	bbh_logger_print(log, __FILE__, sizeof(__FILE__)-1, __func__, sizeof(__func__)-1, __LINE__, \
	level, format, ##args)

#define klogger_fatal(log, format, args...) klogger_print(log, BBH_LOGGER_LEVEL_FATAL, format, ##args)
#define klogger_error(log, format, args...) klogger_print(log, BBH_LOGGER_LEVEL_ERROR, format, ##args)
#define klogger_warn(log, format, args...) klogger_print(log, BBH_LOGGER_LEVEL_WARN, format, ##args)
#define klogger_notice(log, format, args...) klogger_print(log, BBH_LOGGER_LEVEL_NOTICE, format, ##args)
#define klogger_info(log, format, args...) klogger_print(log, BBH_LOGGER_LEVEL_INFO, format, ##args)
#define klogger_debug(log, format, args...) klogger_print(log, BBH_LOGGER_LEVEL_DEBUG, format, ##args)
 
#define logger_write(level, buf, buf_len) \
	bbh_logger_write(logger_instance(), __FILE__, sizeof(__FILE__)-1, __func__, sizeof(__func__)-1, __LINE__, \
	level, buf, buf_len)

#define logger_print(level, format, args...) \
	bbh_logger_print(logger_instance(), __FILE__, sizeof(__FILE__)-1, __func__, sizeof(__func__)-1, __LINE__, \
	level, format, ##args)

#define logger_fatal(format, args...) logger_print(BBH_LOGGER_LEVEL_FATAL, format, ##args)
#define logger_error(format, args...) logger_print(BBH_LOGGER_LEVEL_ERROR, format, ##args)
#define logger_warn(format, args...) logger_print(BBH_LOGGER_LEVEL_WARN, format, ##args)
#define logger_notice(format, args...) logger_print(BBH_LOGGER_LEVEL_NOTICE, format, ##args)
#define logger_info(format, args...) logger_print(BBH_LOGGER_LEVEL_INFO, format, ##args)
#define logger_debug(format, args...) logger_print(BBH_LOGGER_LEVEL_DEBUG, format, ##args)


#ifdef __cplusplus
}
#endif
#endif